﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;

namespace MyLocalChurch
{
    // http://www.codeproject.com/Tips/430320/Previewing-Image-in-ASP-NET-Image-Control-using-Cs
    public class ImageHandler : IHttpHandler, IRequiresSessionState
    {
        public const string SessionName = "PhotoUploadImageBytes";

        public void ProcessRequest(HttpContext context)
        {
            //Checking whether the imagebytes session variable have anything else not doing anything
            if ((context.Session[SessionName]) == null)
                return;

            var image = (byte[])(context.Session[SessionName]);
            context.Response.ContentType = "image/JPEG";
            context.Response.BinaryWrite(image);
        }

        public bool IsReusable
        {
            get { return false; }
        }
    }
}